oo::class create MultiYScroll {
    variable PadWidget MultiWidgets

    constructor {padWidget} {
        set PadWidget $padWidget
        set MultiWidgets {}

        scrollbar ${PadWidget}Scrollbar -command [list $PadWidget yview]
        pack ${PadWidget}Scrollbar -side right -fill y
        my appendWidget _$PadWidget
    }

    method appendWidget {w} {
        lappend MultiWidgets $w
        $w configure -yscrollcommand [list [self object] scrollWidgets]
    }

    method removeWidget {widget} {
        set i 0
        foreach w $MultiWidgets {
            if {$w == $widget} {
                set MultiWidgets [lreplace $MultiWidgets $i $i]
                return
            }
            incr i
        }
    }

    method scrollWidgets {from to} {
        ${PadWidget}Scrollbar set $from $to
        foreach w $MultiWidgets {
            $w yview moveto $from
        }
    }

    destructor {
        foreach widget $MultiWidgets {
            destroy $widget
        }
        destroy $PadWidget
        destroy ${PadWidget}Scrollbar
    }
}